/**
 * Copyright 2011 Joe Choi, All rights reserved.
 */
package tao.calendar.gregorian;

import tao.calendar.gregorian.Gregorian.Unit;

/**
 * The GregorianUnitAmount class store the unit-value pair to 
 * represent the amount of specific unit of time
 * 
 * @author Joe Choi
 * @version 1.0.0
 */
public class GregorianUnitAmount {
	public GregorianUnitAmount(Unit unit, int value) {
		setUnit(unit);
		setValue(value);
	}
	
	public Unit getUnit() {
		return(unit);
	}
	
	private void setUnit(Unit unit) {
		this.unit = unit;
	}
	
	public int getValue() {
		return(value);
	}
	
	private void setValue(int value) {
		this.value = value;
	}
	
	@Override
	public String toString() {
		return(unit + ":" + value);
	}
	
	@Override
	public boolean equals(Object obj) {
		if(! (obj instanceof GregorianUnitAmount)) return(false);
		GregorianUnitAmount other = (GregorianUnitAmount) obj;
		return(this.getUnit() == other.getUnit() && this.getValue() == other.getValue());
	}
	
	@Override
	public int hashCode() {
		return(unit.hashCode() + value);
	}
	
	private Unit unit;
	private int value;
}
